

//
//  UIView+Extension.swift
//  Sina
//
//  Created by YYY on 2017/7/27.
//  Copyright © 2017年 成品家（北京）网路科技有限公司. All rights reserved.
//

//import Foundation
//import UIKit

extension UIView
{
    static let shared: UIView = {
        let instance = UIView()
        return instance
    }()
    
    //X
    var x: CGFloat
    {
        return self.frame.origin.x
    }
    func x(newX: CGFloat)
    {
        var newFrame = self.frame
        newFrame.origin.x = newX
        self.frame = newFrame
    }
    
    //Y
    var y: CGFloat
    {
        return self.frame.origin.y
    }
    func y(newY: CGFloat)
    {
        var newFrame = self.frame
        newFrame.origin.y = newY
        self.frame = newFrame
    }
    
    //宽
    var width: CGFloat
    {
        return self.frame.size.width
    }

    func width(newWidth: CGFloat)
    {
        var newFrame = self.frame
        newFrame.size.width = newWidth
        self.frame = newFrame
    }
    //高
    var height: CGFloat
    {
        return self.frame.size.height
    }
    func height(newHeight: CGFloat)
    {
        var newFrame = self.frame
        newFrame.size.height = newHeight
        self.frame = newFrame
    }
    
    //顶部
    var top: CGFloat
    {
        return self.frame.origin.y
    }
    func top(newTop: CGFloat)
    {
        var newFrame = self.frame
        newFrame.origin.y = newTop
        self.frame = newFrame
    }
    
    //左
    var left: CGFloat
    {
        return self.frame.origin.x
    }
    func left(newLeft: CGFloat)
    {
        var newFrame = self.frame
        newFrame.origin.x = newLeft
        self.frame = newFrame
    }
    
    //底部
    var bottom: CGFloat
    {
        return self.frame.origin.y + self.frame.size.height
    }
    func bottom(newBottom: CGFloat)
    {
        var newFrame = self.frame
        newFrame.origin.y = newBottom - newFrame.size.height
        self.frame = newFrame
    }
    
    //右
    var right: CGFloat
    {
        return self.frame.origin.x + self.frame.size.width
    }
    func right(newRight: CGFloat)
    {
        let edge = newRight - right
        
        var newFrame = self.frame
        newFrame.origin.x += edge
        self.frame = newFrame
    }
    
    //size大小
    var size: CGSize
    {
        return self.frame.size
    }
    func size(newSize: CGSize)
    {
        var newFrame = self.frame
        newFrame.size = newSize
        self.frame = newFrame
    }
    
    //坐标
    var orgin: CGPoint
    {
        return self.frame.origin
    }
    func orgin(newOrgin: CGPoint)
    {
        var newFrame = self.frame
        newFrame.origin = newOrgin
        self.frame = newFrame
    }
    
    //中心点 X
    var centerX: CGFloat
    {
        return self.center.x
    }
    func centerX(newCenterX: CGFloat)
    {
        var newCenter = self.center
        newCenter.x = newCenterX
        self.center = newCenter
    }
    
    //中心点 Y
    var centerY: CGFloat
    {
        return self.center.y
    }
    func centerY(newCenterY: CGFloat)
    {
        var newCenter = self.center
        newCenter.y = newCenterY
        self.center = newCenter
    }
    
}


